import 'core-js/stable'
import 'regenerator-runtime/runtime'
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import download from './utils/download.js'
import dayjs from "dayjs";
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';
import store from './store/'
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
import {VueAxios} from './utils/request'
import {NewVueAxios} from './utils/newRequest'
import VueCropper from 'vue-cropper'
// WARNING: `mockjs` NOT SUPPORT `IE` PLEASE DO NOT USE IN `production` ENV.
import './mock'
import './assets/style/index.css'
import './components/global.less'
import bootstrap from './core/bootstrap'
import './core/lazy_use'
import './permission' // permission control
import './utils/filter' // global filter
import {Dialog} from './components/index.js'
import {
  hasBtnPermission,
  hasPermi,//根据按钮权限判断
  hasRole,
  hasRoleNoAdmin, //根据角色编码判断角色
  hasRoleNo,
} from './utils/permissions' // button permission
import {sysApplication} from './utils/applocation'
import {
  ORDER_TYPE_ENUM,
  MATERIAL_TYPE_ENUM,
  EXECUTE_STATUS_ENUM,
  ORG_TYPE_ENUM,
  BOM_TYPE_ENUM,
  BOM_TYPE_ENUM_ALL,
  appendTime,  //给时间后端拼上时分秒
  createYearList, //生成从2022至今的年份
} from './utils/util'
import util from './utils/util'


// 组件
import Export from '@/components/Export/index.vue'  //导出
import Import from '@/components/Import/index.vue'  //导入
import UploadImageOne from '@/components/pbUpload/UploadImageOne.vue'  //单图上传
import UploadImageMore from '@/components/pbUpload/UploadImageMore.vue'  //多图上传
import ImagePreview from '@/components/pbUpload/ImagePreview.vue'  //图片预览
import ImagePreview1 from '@/components/pbUpload/ImagePreview1.vue'  //图片预览

import CropperUpload from "./components/Upload/CropperUpload.vue";


// 懒加载插件
import VueLazyload from 'vue-lazyload'
import Mixin from "@/mixins/mixin";

Vue.use(Antd);

Vue.use(VueLazyload, {
  preload: 1.3, // 表示lazyload元素距离底部距离百分比
  loading: require('./assets/zhanwei.png'), // 正在加载时显示的图片路径
  error: require('./assets/zhanwei.png'), // 图片加载失败时显示的图片路径
  attempt: 5, // 图片加载失败后重试次数，默认3
})
Vue.use(VueAxios)
Vue.use(Viewer,)
Vue.use(NewVueAxios)
Vue.use(Dialog)
Vue.use(VueCropper)

Viewer.setDefaults({
  'inline': false,
  'button': true,
  'navbar': true,
  'title': true,
  'toolbar': true,
  'tooltip': true,
  'movable': true,
  'zoomable': true,
  'rotatable': true,
  'scalable': true,
  'transition': true,
  'fullscreen': true,
  'keyboard': true,
})


Vue.prototype.hasPerm = hasBtnPermission
Vue.prototype.hasRole = hasRole
Vue.prototype.hasPermi = hasPermi  //角色权限校验(拥有其中一个角色就返回true)

Vue.prototype.hasRoleNoAdmin = hasRoleNoAdmin  //角色权限校验(拥有其中一个角色就返回true)
Vue.prototype.hasRoleNo = hasRoleNo  //判断是否不具有所传过来的角色，如果传多个，必须同时没有才返回true
Vue.prototype.applocation = sysApplication
Vue.prototype.$businessEnum = {
  ORDER_TYPE_ENUM,
  MATERIAL_TYPE_ENUM,
  EXECUTE_STATUS_ENUM,
  ORG_TYPE_ENUM,
  BOM_TYPE_ENUM,
  BOM_TYPE_ENUM_ALL
}
Vue.prototype.$util = util
Vue.prototype.$isDev = process.env.NODE_ENV == 'development'
Vue.prototype.download = download  //通用下载方法
Vue.prototype.dayjs = dayjs;
Vue.prototype.appendTime = appendTime;
Vue.prototype.createYearList = createYearList;


Vue.config.productionTip = false


//自定义指令，按钮防抖
Vue.directive('noMoreClick', {
  inserted(element, binding) {
    const el = element as HTMLInputElement
    el.addEventListener('click', e => {
      el.classList.add('is-disabled')
      el.disabled = true
      setTimeout(() => {
        el.disabled = false
        el.classList.remove('is-disabled')
      }, 1000) //我这里设置的是1000毫秒也就是1秒
    })
  }
})


// 使用组件
Vue.component('Export', Export)
Vue.component('Import', Import)
Vue.component('UploadImageOne', UploadImageOne)
Vue.component('UploadImageMore', UploadImageMore)
Vue.component('ImagePreview', ImagePreview)
Vue.component('ImagePreview1', ImagePreview1)

// @ts-ignore
Vue.component('CropperUpload', CropperUpload)

Vue.mixin(Mixin)
// document.addEventListener('contextmenu', handleContextMenu);
// function handleContextMenu(e) {
// 	 e.preventDefault();
// }
new Vue({
  router,
  store,
	// created() {
	// 	bootstrap,
  //   document.addEventListener('contextmenu', this.handleContextMenu);
  // },
  // beforeDestroy() {
  //   document.removeEventListener('contextmenu', this.handleContextMenu);
  // },
  // methods: {
  //   handleContextMenu(e) {
  //     e.preventDefault();
  //   }
  // },
  created: bootstrap,
  render: h => h(App)
}).$mount('#app')
